<template>
  <div class="app-container">
    <div style="margin-top: 20px">
      <svg-icon icon-class="marker" style="color: #606266"></svg-icon>
      <span class="font-small">基本信息</span>
    </div>
    <div class="table-layout">
      <el-row>
        <el-col :span="6" class="table-cell-title">服务名称</el-col>
        <el-col :span="6" class="table-cell-title">ID</el-col>
        <el-col :span="12" class="table-cell-title">服务方式</el-col>
      </el-row>
      <el-row>
        <el-col :span="6" class="table-cell">{{ res.prodName }}</el-col>
        <el-col :span="6" class="table-cell">{{ res.prodSpecId }}</el-col>
        <el-col :span="12" class="table-cell">{{ prodType[res.prodType] }}</el-col>
      </el-row>
      <el-row>
        <el-col :span="6" class="table-cell-title">服务机构</el-col>
        <el-col :span="6" class="table-cell-title" style="height:37px">机构场地</el-col>
        <el-col :span="12" class="table-cell-title" style="height:37px">服务分类</el-col>
      </el-row>
      <el-row>
        <el-col :span="6" class="table-cell">{{ res.channelName }}</el-col>
        <el-col :span="6" class="table-cell">{{ res.dealershipName }}</el-col>
        <el-col :span="12" class="table-cell">{{ res.serverSpecName }}</el-col>
      </el-row>
    </div>
    <div style="margin-top: 20px">
      <svg-icon icon-class="marker" style="color: #606266"></svg-icon>
      <span class="font-small">服务区域</span>
    </div>
    <div style="margin-top: 20px">
      <el-row>
        <el-col :span="6" class="table-cell" style="border: 1px solid #DCDFE6;" v-for="(item,index) in res.releaseAreaList" :key="index">{{ item }}</el-col>
      </el-row>
    </div>
    <div style="margin-top: 20px">
      <svg-icon icon-class="marker" style="color: #606266"></svg-icon>
      <span class="font-small">属性列表</span>
    </div>
    <div class="table-layout">
      <el-table
        :data="res.prptyShowList"
        border
        style="width: 100%">
        <el-table-column
          prop="prptyName"
          label="属性名">
        </el-table-column>
        <el-table-column
          prop="prptyType"
          label="类型">
        </el-table-column>
        <el-table-column
          prop="values"
          label="属性值">
        </el-table-column>
      </el-table>
    </div>
    <div style="margin-top: 20px">
      <svg-icon icon-class="marker" style="color: #606266"></svg-icon>
      <span class="font-small">规格价格、服务时段、库存</span>
    </div>
    <div class="table-layout">
      <el-table
        :data="res.skuTableData"
        border
        style="width: 100%">
        <el-table-column
          v-for="(item,i) in res.labelArray"
          :key="i"
          :prop="item.prop"
          :label="item.label">
        </el-table-column>
      </el-table>
    </div>
    <el-row type="flex" justify="end" style="margin-top: 20px">
      <el-col :span="2">
        <el-button @click="back">返回</el-button>
      </el-col>
    </el-row>

  </div>
</template>
<script>

import { getProdViewById } from '@/api/deptInst'
import { formatDate } from '@/utils/date'
export default {
  name: 'CourseList',
  data () {
    return {
      res: {},
      prodType: {
        '1': '到店',
        '2': '上门'
      }
    }
  },
  created () {
    getProdViewById({ prodId: this.$route.query.prodId }).then(response => {
      this.res = response.data
    })
  },
  filters: {
    formatDateTime (time) {
      if (time == null || time === '') {
        return 'N/A'
      }
      const date = new Date(time)
      return formatDate(date, 'yyyy-MM-dd hh:mm:ss')
    }
  },
  methods: {
    back () {
      this.$router.go(-1)
    }

  }
}
</script>
<style scoped>
  .app-container {
    width: 80%;
    margin: 20px auto;
  }

  .table-layout {
    margin-top: 20px;
    border-left: 1px solid #DCDFE6;
    border-top: 1px solid #DCDFE6;
  }

  .table-cell {
    height: 60px;
    line-height: 40px;
    border-right: 1px solid #DCDFE6;
    border-bottom: 1px solid #DCDFE6;
    padding: 10px;
    font-size: 14px;
    color: #606266;
    text-align: center;
    overflow: hidden;
  }

  .table-cell-title {
    border-right: 1px solid #DCDFE6;
    border-bottom: 1px solid #DCDFE6;
    padding: 10px;
    background: #F2F6FC;
    text-align: center;
    font-size: 14px;
    color: #303133;
  }

  .coursePic {
    margin-top: 20px;
    max-width: 100%;
  }
</style>
